package OperationSystem.day1206.OutputStream.spy;

import java.io.*;

public class Application3 {
    public static void main(String[] args) throws IOException {

        String srcPath = "UTF-8编码的文件.txt";
        String destPath = "GBK编码的文件.txt";

        try (Reader reader = new InputStreamReader(new FileInputStream(srcPath), "UTF-8")) {
            try (Writer writer = new OutputStreamWriter(new FileOutputStream(destPath), "GBK")) {
                char[] buffer = new char[2048];
                int len;
                while ((len = reader.read(buffer)) != -1) {
                    writer.append(new String(buffer, 0, len));
                }
                writer.flush();
            }
        }
    }
}
